package opencv.service.examples;


import java.awt.Image;

import opencv.service.Application;
import opencv.service.SimpleDebugGUI;
import opencv.service.algorithms.MarkerDetectionAlgorithm;

import com.googlecode.javacv.Marker;
import com.googlecode.javacv.jna.cxcore.IplImage;

/**
 * @author Aakash Polra
 */
public class MarkerDetection extends SimpleDebugGUI {

	private static final long serialVersionUID = 1L;

	@Override
	protected void initApplication() {
		final MarkerDetectionAlgorithm markerDetectionAlgorithm = new MarkerDetectionAlgorithm() {
			@Override
			public void onDebugImagePrepared(Image image) {
				showDebug(image);
			}
		};
		
		application = new Application() {
			public void onAfterAlgorithmsRan(IplImage lastFrame, IplImage currentFrame) {
				Marker[] markers = markerDetectionAlgorithm.getDetectedMarkers();
				
				if (markers != null && markers.length > 0) {
					System.out.println("" + markers.length + " markers detected...");
				}
			};
		};
		application.getAlgorithms().add(markerDetectionAlgorithm);
	}
	
	public static void main(String[] args) {
		MarkerDetection app = new MarkerDetection();
		app.showFrame();
	}
}
